package com.example.demo01.controller;

import com.example.demo01.api.DemoApi;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName DemoController
 * @Description
 * @Author zhangsw
 * @Date 2021/10/19 22:54
 * @Version 1.0
 */
@RestController
@RequestMapping("demo")
public class DemoController {

    @Resource
    DemoApi demoApi;

    @PostMapping("hello")
    public Map<String, Object> hello(@RequestBody Map<String, Object> param) {
        Map<String, Object> objectMap = demoApi.demo1(param);
        System.out.println(objectMap);
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("data", objectMap);
        return map;
    }

    @PostMapping("hello2")
    public Map<String, Object> hello2(@RequestBody Map<String, Object> param) {
        System.err.println("hello2 \n" + param);
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("data", param);
        return map;
    }

    @GetMapping("getHello2")
    public Map<String, Object> getHello2(String param) {
        System.err.println("hello2 \n" + param);
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("data", param);
        return map;
    }
}
